How can I optimize my Java solution to find K pairs with the smallest sums in O(n log n)